/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package scheduletask;

import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
public class LogFile {
    
    
   
    public static void log(String owner,String logtxt)
    {
     PrintWriter fw ;
        try {
           
              SimpleDateFormat sdf=new SimpleDateFormat("dd-MM-yyyy");
             String filename=sdf.format(new Date());
              DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
        DocumentBuilder builder=factory.newDocumentBuilder();
       
        Document config= builder.parse("config.xml");
        Element logpathelement=(Element)config.getElementsByTagName("log-path").item(0);
             
             
            String path=logpathelement.getTextContent()+"\\"+filename+".txt";
            System.out.println(path);
            FileOutputStream out=new FileOutputStream(path, true);
            PrintWriter pw=new PrintWriter(out, true);
            pw.println(owner+" "+logtxt+"<br>");
            pw.close();
            out.close();
        } catch (Exception ex) {
            Logger.getLogger(LogFile.class.getName()).log(Level.SEVERE, null, ex);
        } 
    }
    
    

 
    
}

